QuickTime 3 Reference

Previous | Chapter Top | Chapter Contents | Next

Supporting Progressive Downloads

The Movie Toolbox includes functions for supporting progressive downloads of movies. These functions are illustrated in the following sections.

Displaying a Progressively Downloaded Movie

Listing 18 illustrates how to use the QTMovieNeedsTimeTable function to find out if a movie if being progressively downloaded and the GetMaxLoadedTimeInMovie function to find out how much of the movie has been downloaded.

Listing 18Displaying a progressively downloaded movie

WindowPtr   movieWindow;
Movie       theMovie;
Boolean     needsTimeTable;
TimeValue   loadedTime = -1;

err = GetDisplayedMovie (&movieWindow, &theMovie);
if (err) goto bail;
err = QTMovieNeedsTimeTable (theMovie, &needsTimeTable);
if (err) goto bail;

if (needsTimeTable)
{
    err = GetMaxLoadedTimeInMovie (theMovie, &loadedTime);
    // Display the movie up to the current end
}

Creating a Track Time Table

Listing 19 illustrates how to use the MakeTrackTimeTable function to create a time table for the tracks in a movie.

Listing 19 Creating a time table for movie tracks

OSErr       theErr = noErr;
WindowPtr   movieWindow = nil;
Movie       theMovie = nil;
Track       theTrack;
long        trackCount,
            trackIndex,
            retDataRefSkew;
TimeValue   startTime,
            endTime,
            timeIncrement;
short       firstDataRefIndex,
            lastDataRefIndex;
                    
Handle      offsets,
            offsetsSet [32];

err = GetDisplayedMovie (&movieWindow, &theMovie);
if (err) goto bail;

timeIncrement = GetMovieTimeScale (theMovie);
firstDataRefIndex = -1;
lastDataRefIndex = -1;
trackCount = GetMovieTrackCount (theMovie);

for (trackIndex = 1; trackIndex <= trackCount; trackIndex++)
{
    theTrack = GetMovieIndTrack (theMovie, trackIndex);
    offsets = NewHandle (0);
    offsetsSet [trackIndex - 1] = offsets;
    startTime = GetTrackOffset (theTrack);
    endTime = GetTrackDuration (theTrack);
    err = MakeTrackTimeTable (theTrack, (long **) offsets,
                startTime, endTime, timeIncrement,
                firstDataRefIndex, lastDataRefIndex, &retDataRefSkew);
    if (err) goto bail;

    // check data
    }
    
for (trackIndex = 1; trackIndex <= trackCount; trackIndex++)
{
    DisposeHandle (offsetsSet [trackIndex - 1]);
}

Creating a Media Time Table

Listing 20 illustrates how to use the MakeMediaTimeTable function to create a time table for media.

Listing 20 Creating a time table for media

OSErr       theErr = noErr;
WindowPtr   movieWindow = nil;
Movie       theMovie = nil;
Track       theTrack;
Media       theMedia;
long        trackCount,
            trackIndex,
            retDataRefSkew;
TimeValue   startTime,
            endTime,
            timeIncrement;
short       firstDataRefIndex,
            lastDataRefIndex;
Handle      offsets,
            offsetsSet [32];

err = GetDisplayedMovie (&movieWindow, &theMovie);
if (err) goto bail;

firstDataRefIndex = -1;
lastDataRefIndex = -1;
        
trackCount = GetMovieTrackCount (theMovie);
            
for (trackIndex = 1; trackIndex <= trackCount; trackIndex++)
{
    theTrack = GetMovieIndTrack (theMovie, trackIndex);
    theMedia = GetTrackMedia (theTrack);
    offsets = NewHandle (0);
    offsetsSet [trackIndex - 1] = offsets;
    startTime = GetTrackOffset (theTrack);
    startTime = TrackTimeToMediaTime (startTime, theTrack);
    endTime = GetTrackDuration (theTrack);
    endTime = TrackTimeToMediaTime (endTime, theTrack);
    timeIncrement = GetMediaTimeScale (theMedia);
    err = MakeMediaTimeTable (theMedia, (long **) offsets,
                startTime, endTime, timeIncrement, firstDataRefIndex,
                lastDataRefIndex, &retDataRefSkew);
    if (err) goto bail;
    
    // check data
}
    
for (trackIndex = 1; trackIndex <= trackCount; trackIndex++)
{
    DisposeHandle (offsetsSet [trackIndex - 1]);
}

© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next